
module.exports = app => {
  const mongoose = app.mongoose

  const FlowsSchema = new mongoose.Schema({
    uploadspeed: { type: Number, required: true, default: 0 },
    downloadspeed: { type: Number, required: true, default: 0 },
    timestamp: { type: Date, required: true },
    device: { type: mongoose.Schema.Types.ObjectId, ref: 'Devices' }

  }, { timestamps: false })

  FlowsSchema.methods.toString = function () {
    return this.timestamp
  }

  FlowsSchema.index({ _id: 1, timestamp: -1 })

  return mongoose.model('Flows', FlowsSchema)
}


